package com.lixinlei.springboot_servlet.controller.argumentsresolver.RequestParam;

import com.lixinlei.springboot_servlet.controller.argumentsresolver.RequestBody.Student;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(path = "/request/param")
public class RequestParamController {

    /**
     * /request/mapping/path1?firstName=Guang&lastName=shan&lastName=6666
     * 注意：这个东西 MultiValueMap 没法以 JSON 的格式返回；
     * @param params
     * @return
     */
    @RequestMapping(path = "/path1")
    public MultiValueMap<String, String> requestParam1(@RequestParam MultiValueMap<String, String> params) {
        System.out.println("*****************requestParam1()");
        return params;
    }

    /**
     * 普通的 JavaBean 可以以 JSON 的格式返回；
     * @return
     */
    @RequestMapping(path = "/path2")
    public Student path1() {
        Student s = new Student();
        s.setId(2222);
        s.setName("lxl");
        return s;
    }

}
